package cn.imu.config;

import cn.imu.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration
public class WebConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    //配置资源过滤，比如js、css、html
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

    }

    //配置拦截器，写好的拦截器需要到这里注册才行
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //过滤/**下的所有请求，不过滤/login,/,/toLogin请求
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/login","/register","/","toLogin");
    }
}
